<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

/**
 * SimplyPost
 *
 * @author		Pascal Kriete
 * @package		SimplyPost
 * @copyright	Copyright (c) 2008, Pascal Kriete
 * @license 	http://www.gnu.org/licenses/lgpl.txt
 */

// ------------------------------------------------------------------------

/**
 * Post Admin Controller
 *
 * @package		SimplyPost
 * @subpackage	Post
 * @category	Controller
 * @author		Pascal Kriete
 */

class Admin extends Administrator {
	
	/**
	 * Constructor
	 *
	 * @access	public
	 */
	function Admin()
	{
		parent::Administrator();
	}
	
	// ------------------------------------------------------------------------
	
	/**
	 * No real function - redirects
	 *
	 * @access	public
	 */
	function index()
	{
		redirect('admin/');
	}
	
	// ------------------------------------------------------------------------

	/**
	 * Delete a Post
	 *
	 * @access	public
	 * @param	integer	post id
	 * @param	integer	topic id
	 */
	function delete($id, $topic)
	{
		$this->load->model('Post_model', 'Post');
		$p = $this->Post->get_post($id);
		$this->Post->delete($id);
		
		$this->load->model('member/User_model', 'User');
		$this->User->remove_post($p['user_id']);

		$this->session->set_flashdata('msg', 'Post Deleted!');
		redirect('topic/view/'.$topic);
	}
}